/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package SearchModels;

/**
 *
 * @author Israel Agyeman-Premp
 */
public class Logic {

    public void search(String words) {
        String newWord = convertToSearchable(words);
        try {
            //Set your page url in this string. For eg, I m using URL for Google Search engine
            String url = "https://www.google.com/search?q="+newWord;
            java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
            System.out.println("About to search: "+newWord);
        } catch (java.io.IOException ex) {
            System.out.println(ex.getMessage());
        }
    }
    
    public void searchYoutube(String words) {
        String newWord = convertToSearchable(words);
        try {
            //Set your page url in this string. For eg, I m using URL for Google Search engine
            String url = "https://www.youtube.com/results?search_query="+newWord;
            java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
            System.out.println("About to search: "+newWord);
        } catch (java.io.IOException ex) {
            System.out.println(ex.getMessage());
        }
    }
    
    private String convertToSearchable(String words) {
        return  words.replaceAll(" ","+");
    }

}
